package com.cts.tmall.app.controller;

import com.cts.tmall.biz.service.MoneyOffService;
import com.cts.tmall.dal.entity.TmallMoneyOff;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/moneyOff")
public class MoneyOffController {

    @Autowired
    private MoneyOffService moneyOffService;

    @GetMapping
    public Map<String, Object> queryMoneyOff(
            @RequestParam(name = "createUserId", required = false) Long createUserId,
            @RequestParam(name = "eventName", required = false) String eventName,
            @RequestParam(name = "status", required = false) String status,
            @RequestParam(name = "pageNumb", required = false, defaultValue = "1") Long pageNumb,
            @RequestParam(name = "pageSize", required = false, defaultValue = "10") Long pageSize) {
        return moneyOffService.queryMoneyOff(createUserId,eventName, status, pageNumb, pageSize);
    }

    @PostMapping
    public TmallMoneyOff addMoneyOff(@RequestBody TmallMoneyOff moneyOff) {
        return moneyOffService.addMoneyOff(moneyOff);
    }

    @PutMapping
    public TmallMoneyOff updMoneyOff(@RequestBody TmallMoneyOff moneyOff) {
        return moneyOffService.updMoneyOff(moneyOff);
    }
}
